/******************************************************************************
*	usbd/devicerequest.h
*	 by Alex Chadwick
*
*	A light weight implementation of the USB protocol stack fit for a simple
*	driver.
*
*	usbd/devicerequest.h contains a definition of the standard device
*	request structure defined in USB2.0
******************************************************************************/
#ifndef _USBD_DEVICEREQUEST_H
#define _USBD_DEVICEREQUEST_H

#include <types.h>

//------------------------------------------------------------------------------
// A device request is a standard mechanism for negotiations with devices.
// Defined in "USB Sepcification, Rev 2.0, 27/Apr/2000" section 9.3
//
// The requests have a number of parameters, and so are best implemented with a structure.
// Since this structure is arbitrary, we shall match Linux in the hope of achieving compatibility.
//
typedef
	enum UsbDeviceRequestRequest {
		// USB requests
		GetStatus        =  0,
		ClearFeature     =  1,
		SetFeature       =  3,
		SetAddress       =  5,
		GetDescriptor    =  6,
		SetDescriptor    =  7,
		GetConfiguration =  8,
		SetConfiguration =  9,
		GetInterface     = 10,
		SetInterface     = 11,
		SynchFrame       = 12,

		// HID requests
		GetReport        = 1,
		GetIdle          = 2,
		GetProtocol      = 3,
		SetReport        = 9,
		SetIdle          = 10,
		SetProtocol      = 11,
	}
UsbDeviceRequestRequest;

typedef
	struct UsbDeviceRequest {
		u8                      Type;         // +0x0
		UsbDeviceRequestRequest Request : 8;  // +0x1
		u16                     Value;        // +0x2
		u16                     Index;        // +0x4
		u16                     Length;       // +0x6
	}
UsbDeviceRequest;

#endif // _USBD_DEVICEREQUEST_H
